<%@page import="java.util.ArrayList"%>
<%@page import="entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<!-- EL从域对象中取出数据(EL最重要的作用) -->
	<%
		// 1、普通字符串
		pageContext.setAttribute("name", "lisi");
		request.setAttribute("name", "zhangsan");
		// 2、Studnt对象
		Student student = new Student(1, "张三", 23, "男");
		session.setAttribute("student", student);
		// 3、ArrayList<Student> 
		ArrayList<Student> list = new ArrayList<Student>();
		Student student1 = new Student(1, "张三1", 23, "男");
		Student student2 = new Student(3, "张三2", 23, "男");
		Student student3 = new Student(3, "张三3", 23, "男");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		application.setAttribute("list", list);
	%>
	
	<!-- 1、获取字符串 -->
	<!-- 使用JSP表达式 -->
	<%=pageContext.getAttribute("name")%><br/>
	<%=request.getAttribute("name")%><br/>
	<!-- EL表达式 -->
	${pageScope.name}<br/>
	${requestScope.name}<br/>
	${name}
	<hr/>
	
	<!-- 2、Studnt对象 -->
	<!-- 使用JSP表达式 -->
	<%
		// Duplicate local variable student
		Student stu = (Student)session.getAttribute("student");
	%>
	<%=stu.getName()%><br/>
	<%=stu.getAge()%><br/>
	<!-- EL表达式 -->
	${sessionScope.student.name}<br/>
	${student}<br/>
	${student.name}<br/>
	${student.age}<br/>
	<hr/>
	
	<!--  3、ArrayList<Student>  -->
	<!-- 使用JSP表达式 -->
	<%
		ArrayList<Student> stuList = (ArrayList<Student>)application.getAttribute("list");
	%>
	<%=stuList.get(0)%><br/>
	<%=stuList.get(0).getName()%><br/>
	<!-- EL表达式 -->
	${applicationScope.list[0]}<br/>
	${list[0].name}<br/>
	<hr/>
	
	<%=request.getContextPath()%><br/>
	${pageContext.request.contextPath}
</body>
</html>